Kanzi  3.9.7
Android application framework API
KanziView Class Reference

A view that owns the native Kanzi application and provides the output surface. More...

Inheritance diagram for KanziView:
[legend]

Classes

enum  State
 KanziView java-side lifecycle state.
 

Public Member Functions

 KanziView (Context context)
 Simple constructor to use when creating a KanziView from code. More...
 
 KanziView (Context context, AttributeSet attrs)
 Constructor that is called when inflating a KanziView from XML. More...
 
void createNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_CREATE events. More...
 
void destroyNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_DESTROY events. More...
 
boolean onKeyDown (final int keyCode, KeyEvent event)
 A key down handler. More...
 
boolean onKeyUp (final int keyCode, KeyEvent event)
 A key up handler. More...
 
boolean onTouchEvent (final MotionEvent event)
 Handler for touches inside KanziView. More...
 
void pauseNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_PAUSE events. More...
 
int queueEvent (Runnable runnable)
 Submits a runnable task to Kanzi's task dispatcher. More...
 
void registerLifecycle (Lifecycle lifecycle)
 Attaches KanziView to the given Lifecycle. More...
 
void resumeNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_RESUME events. More...
 
void setOrientation (int orientation)
 Handler for device/display orientation changes. More...
 
void startNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_START events. More...
 
void stopNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_STOP events. More...
 
void surfaceChanged (SurfaceHolder holder, int format, int width, int height)
 This is called immediately after any structural changes (format or size) have been made to the surface. More...
 
void surfaceCreated (SurfaceHolder holder)
 This is called immediately after the surface is first created. More...
 
void surfaceDestroyed (SurfaceHolder holder)
 This is called immediately before a surface is being destroyed. More...
 

Protected Member Functions

boolean isActiveView ()
 Checks is this instance the same which was passed to the native application by createNativeApplication(). More...
 
void onFocusChanged (boolean gainFocus, int direction, Rect previouslyFocusedRect)
 Called by the view system when the focus state of this KanziView changes. More...
 

Protected Attributes

State mState = State.IDLE
 Current KanziView lifecycle state.
 
Surface mSurface = null
 Valid Surface. More...
 

Detailed Description

A view that owns the native Kanzi application and provides the output surface.

Constructor & Destructor Documentation

KanziView ( Context  context)

Simple constructor to use when creating a KanziView from code.

Parameters
contextThe Context the KanziView is running in, through which it can access the current theme, resources, etc.
KanziView ( Context  context,
AttributeSet  attrs 
)

Constructor that is called when inflating a KanziView from XML.

Parameters
contextThe Context the KanziView is running in, through which it can access the current theme, resources, etc.
attrsThe attributes of the XML tag that is inflating the KanziView.

Member Function Documentation

void createNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_CREATE events.

Loads the native library providing all Kanzi functionality. Initializes the context and assigns this KanziView for rendering. Creates Kanzi application which loads the Kanzi project.

void destroyNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_DESTROY events.

Halts and destroys the Kanzi application.

boolean isActiveView ( )
protected

Checks is this instance the same which was passed to the native application by createNativeApplication().

Returns
True if they are the same.
void onFocusChanged ( boolean  gainFocus,
int  direction,
Rect  previouslyFocusedRect 
)
protected

Called by the view system when the focus state of this KanziView changes.

Parameters
gainFocusTrue if the KanziView has focus; false otherwise.
directionThe direction focus has moved when requestFocus() is called to give this KanziView focus.
previouslyFocusedRectThe rectangle, in this KanziView's coordinate system, of the previously focused view. May be null.
See also
android.view.View::View(Context context, AttributeSet attrs)
boolean onKeyDown ( final int  keyCode,
KeyEvent  event 
)

A key down handler.

Passes the key down event to the key event handler.

Parameters
keyCodeA key code that represents the button pressed, from android.view.KeyEvent.
eventThe KeyEvent object that defines the button action.
Returns
If the event was handled by the superclass' handler, return true.
boolean onKeyUp ( final int  keyCode,
KeyEvent  event 
)

A key up handler.

Passes the key up event to the key event handler.

Parameters
keyCodeA key code that represents the button pressed, from android.view.KeyEvent.
eventThe KeyEvent object that defines the button action.
Returns
If the event was handled by the superclass' handler, return true.
boolean onTouchEvent ( final MotionEvent  event)

Handler for touches inside KanziView.

Translates the received events into the native library's touch states.

Parameters
eventThe motion event.
Returns
True, always as this is the only touch handler for KanziView.
void pauseNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_PAUSE events.

Logs the event.

int queueEvent ( Runnable  runnable)

Submits a runnable task to Kanzi's task dispatcher.

This function fails if the task dispatcher is not yet initialized.

Parameters
runnableThe task to be run.
Returns
Zero on success, non-zero on failure.
void registerLifecycle ( Lifecycle  lifecycle)

Attaches KanziView to the given Lifecycle.

Parameters
lifecycleThe lifecycle to attach to.
void resumeNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_RESUME events.

Logs the event.

void setOrientation ( int  orientation)

Handler for device/display orientation changes.

Translates the received orientation qualifiers into the native library's orientation constants.

Parameters
orientationThe orientation qualifier from onOrientationChanged().
void startNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_START events.

Runs the Kanzi application if a surface has already been received.

void stopNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_STOP events.

Stops the Kanzi application.

void surfaceChanged ( SurfaceHolder  holder,
int  format,
int  width,
int  height 
)

This is called immediately after any structural changes (format or size) have been made to the surface.

This method is always called at least once, after surfaceCreated.

Parameters
holderThe SurfaceHolder whose surface has changed.
formatThe new PixelFormat of the surface.
widthThe new width of the surface.
heightThe new height of the surface.
void surfaceCreated ( SurfaceHolder  holder)

This is called immediately after the surface is first created.

Passes the created surface to the native library for rendering target.

Parameters
holderThe SurfaceHolder whose surface is being created.
void surfaceDestroyed ( SurfaceHolder  holder)

This is called immediately before a surface is being destroyed.

Parameters
holderThe SurfaceHolder whose surface is being destroyed.

Member Data Documentation

Surface mSurface = null
protected

Valid Surface.

The surface will be captured during the onSurfaceCreated event.